/**
 * Created by Administrator on 2017/9/18.
 */
import {ty_test} from './checkedDataType.js'
var searchParams = function (ty_data) {
  if(!ty_test.isString(ty_data)) return console.error('参数必须为字符串');
  var ostrArry = ty_data.split("&"),get_params = {},oflag = 0;
  while (ostrArry.length - oflag) {
    var little_params = ostrArry[oflag].split('=')
    if (little_params.length == 2) {
      get_params[little_params[0]] = little_params[1];
    }
    else {
      get_params[little_params[0]] = '';
    }
    oflag++;
  };
  return get_params
}
var searchString = function (ty_data, ty_bool) {
  if(!ty_test.isObject(ty_data)) return console.log('参数必须为对象');
  var ostring = []
  for (var okey in ty_data) {
     var smallT = (ty_bool === true) ? (okey + '=' + ty_data) : encodeURIComponent(okey) + '=' + encodeURIComponent(ty_data)
    ostring.push(smallT)
  }
  return ostring.join('&');
}
export default {
  searchParams,
  searchString
}
